﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_WhoCharinfo : ServerBasePacket
    {
        private static Logger _log = Logger.getLogger( typeof( S_WhoCharinfo ).FullName );

        private byte[] _byte = null;

        public S_WhoCharinfo( L1PcInstance pc )
        {
            _log.fine( "Who charpack for : " + pc.getName() );

            String lawfulness = "";
            int lawful = pc.getLawful();
            if ( lawful < 0 )
            {
                lawfulness = "(Chaotic)";
            }
            else if ( lawful >= 0 && lawful < 500 )
            {
                lawfulness = "(Neutral)";
            }
            else if ( lawful >= 500 )
            {
                lawfulness = "(Lawful)";
            }

            writeC( Opcodes.S_OPCODE_SYSMSG );
            writeC( 0x08 );

            String title = "";
            String clan = "";

            if ( pc.getTitle().Equals( "" ) == false )
            {
                title = pc.getTitle() + " ";
            }

            if ( pc.getClanid() > 0 )
            {
                clan = "[" + pc.getClanname() + "]";
            }

            writeS( title + pc.getName() + " " + lawfulness + " " + clan );
            // writeD(0x80157FE4);
            writeD( 0 );
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = _bao.ToArray();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_WhoCharinfo";
        }
    }
}